package com.aixin.csopuser.service;

import com.aixin.csopuser.domain.CustomerServiceConsume;
import com.aixin.csopuser.domain.dto.SupplierCustomerDTO;
import com.aixin.csopuser.domain.vo.CustomerServiceConsumeQuery;
import com.aixin.csopuser.repository.CustomerServiceConsumeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceConsumeService {

    @Autowired
    private CustomerServiceConsumeRepository serviceConsumeRepository;

    public Page<SupplierCustomerDTO> queryList(CustomerServiceConsumeQuery query, Pageable pageable) {
        String statusUnUse = null;
        String statusUsed = null;
        if (query.getUsedStatus() != null && query.getUsedStatus() == 0) {
            statusUnUse = "0";
        } else if (query.getUsedStatus() != null && query.getUsedStatus() == 1) {
            statusUsed = "1";
        }
        return serviceConsumeRepository.query(query.getCustomerName(), query.getIdentity(), query.getSupplierID(), query.getServiceID(), statusUnUse, statusUsed, pageable);
    }
}
